/*
 * Label.h
 *
 *  Created on: 2010-12-17
 *      Author: wenjian
 */

#ifndef LABEL_H_
#define LABEL_H_
#include "../../commons.h"
#include "../../gdiplus/gdraw.h"

using namespace Ed;
using namespace Thk;

namespace S {

  class Label : public Element {
    public:
      Label(real x, real y, real w, real h, const std::wstring& text="");
      virtual ~Label();

      void setText(const std::wstring& text){
        this->text = text;
        setModified(true);
      }

      void setText(const wchar_t* text){
        this->text = text;
        setModified(true);
      }

      /**
       * 画此元素
       */
      void draw(Gdiplus::Graphics* g) {
        g->DrawString(text.c_str(), text.size(), font, *getBoundRect(), &format, brush);
        setModified(false);
        setRedraw(false);
      }

    private:
      std::wstring text;
      Gdiplus::SolidBrush* brush;
      Gdiplus::Font* font;
      Gdiplus::StringFormat format;
  };

}

#endif /* LABEL_H_ */
